<?php
	/* Return the array keys of a tree-structured array */
	 function array_keys_r($array, $search=null) {
		$keys = array();
	 	foreach ($array as $id => $subArray) {
	 		$keys = array_merge($keys, array_keys_r($subArray));
			if(!empty($search)){
				if($id === $search) $keys[] = $id;
			}else{
				$keys[] = $id;
			}
	 	}
	 	return $keys;
	 }
	//
?>